function P=arc_cov(P, dl, dr, kl, kr, B)
C=eye(3);
R = B*(dr+dl)/2/(dr-dl);
a = (dr-dl)/B;
kRsr = abs(B*dr/(dr-dl)*kr*kr);
kRsl = abs(B*dl/(dr-dl)*kl*kl);
ksum = kRsr + kRsl;
kdiff = kRsr - kRsl;
C(1,1) = ksum*R*R/B/B*(3*a/2-2*sin(a)+sin(2*a)/4)+ksum/4*(a/2+sin(2*a)/4) + kdiff*R/B*(sin(a)-a/2-sin(2*a)/4);
C(1,2) = ksum*(R*R/B/B*(3-4*cos(a)+cos(2*a))/4+(cos(2*a)-1)/16)+kdiff*R/4/B*(2*cos(a)-cos(2*a)-1);
C(1,3) = ksum*R/B/B*(a-sin(a))+kdiff*sin(a)/2/B;
C(2,1) = C(1,2);
C(2,2) = (a/2-sin(2*a)/4)*(ksum*(R*R/B/B+0.25)-kdiff*R/B);
C(2,3) = (ksum*R/B/B-kdiff/2/B)*(1-cos(a));
C(3,1) = C(1,3);
C(3,2) = C(2,3);
C(3,3) = ksum/B/B*a;
if (a < 0) C = -1 * C; end
Phi=eye(3);
Phi(2,2)=cos(a);
Phi(1,1)=Phi(2,2);
Phi(1,2) = sin(a);
Phi(1,3) = R*(1-cos(a));
Phi(2,1) = -sin(a);
Phi(2,3) = R*sin(a);
P = Phi*P*Phi'+C;
end